package com.mxsat.system.service.impl;

import java.util.Date;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mxsat.common.enums.dict.DataStatusEnum;
import com.mxsat.system.dao.SysRoleDao;
import com.mxsat.system.entity.SysRole;
import com.mxsat.system.service.SysRoleService;

@Service
public class SysRoleServiceImpl implements SysRoleService {
	
	@Autowired
	private SysRoleDao sysRoleDao;

	public IPage<SysRole> findSysRolesByPage(IPage<SysRole> page,Map<String, Object> condition) throws Exception {
		return sysRoleDao.selectRoleByPage(page, condition);
	}

	@Override
	public SysRole findSysRoleById(Long id) throws Exception {
		return sysRoleDao.getById(id);
	}

	@Override
	public boolean addSysRole(SysRole role) throws Exception {
		Date op = new Date();
		role.setData_status(DataStatusEnum.正常.toCode());
		role.setTime_create(op);
		role.setTime_update(op);
		return sysRoleDao.save(role);
	}

	@Override
	public boolean modifySysRoleById(SysRole role) throws Exception {
		role.setTime_update(new Date());
		return sysRoleDao.updateById(role);
	}

	@Override
	public boolean removeSysRoleById(Long id) throws Exception {
		return sysRoleDao.removeById(id);
	}

}
